import service from '@/utils/request.js'
// 将所有的针对role的请求，都封装到一个对象中
const roleApi = {
    list(roleQuery) {
        return service.get('/role/list', {params: roleQuery})
    },
    selectAll() {
        return service.get('/role/selectAll')
    },
    deleteById(id) {
        return service.delete( `/role/deleteById/${id}`)
    },
    deleteAll(ids) {
        return service.delete( `/role/deleteAll/${ids}`)
    },
    add(role) {
        //role以JSON形式传递到后台，后端使用@RequestBody接收
        return service.post('/role/add', role)
    },
    selectById(id) {
        return service.get(`/role/selectById/${id}`)
    },
    update(role) {
        return service.put('/role/update', role)
    },
    selectAssignedPermission(roleId) {
        return service.get(`/role/selectAssignedPermission/${roleId}`)
    },
    assignPermission(roleId, permissionIds) {
        return service.post('/role/assignPermission', null, {params: {roleId, permissionIds}})
    }
}

export default roleApi